home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * App.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- //var IS = IS_getLibHandle();
- if (!IS.isModuleInitialized("IS.NOF.App"))
- {
- /****h* NOF_JavaScript_Library/NOF.App
- *
- * NAME
- * NOF.App
- *
- * DESCRIPTION
- *
- *
- ****/
-
- /**
- * Constructor
- */
- function NOF_App( ) {
- this.__proto__ = NOF_App.prototype;
-
- this.libsPath = new Array();
-
- this.fsiApp = null;
- this.fsiApp2 = null;
- }
- {
- var member = NOF_App.prototype;
- //TODO:? determine the real file system path separator and file line break
- member.PATH_SEPARATOR = "/";
- member.LINE_BREAK = "\r\n";
-
- /*
- boolean runScript(String scriptPath, String jsExp)
- string getExeLocation()
- string getProfilesPath
- string getSerialNumber
- string getVersion
-
- string getTempDir
- string cleanTempDir
- string copyToTempDir
- string writeTempFile
-
- string getUserSitesPath
-
- string getRecentSiteLocation(int pNumber)
- setCurrentView(int pView)
- NOF.Site newSite(String sitePath)
- NOF.Site openSite(String sitePath)
- NOF.Site getCurrentSite()
- NOF.UTIL.Locale getLocale()
-
- setPassword (name, value, context)
- boolean hasPassword (name)
-
- get/setVariable()
-
- string getScriptsDirectory() //getScriptLibFolderPath()
- DateFormat getDateFormat()
- NumberFormat getNumberFormat ()
- string getEncoding()
- string getPathSeparator() // mac, windows
- string getLineBreak() // mac, windows
- */
-
- var method = NOF_App.prototype;
-
- method.super_release = method.release;
- method.release = function () {
- this.super_release();
- this.fsiApp = null;
- this.fsiApp2 = null;
- }
-
- method.getFSIApp = function () {
- if (this.fsiApp == null) {
- this.fsiApp = new ActiveXObject(NOF.ProgId.FSIApplication);
- }
- return this.fsiApp;
- }
-
- method.getFSIApp2 = function () {
- if (this.fsiApp2 == null) {
- this.fsiApp2 = new ActiveXObject(NOF.ProgId.FSIApplication2);
- }
- return this.fsiApp2;
- }
-
- /**
- * Runs a script in Fusion.
- * @param scriptPath - path to html file
- * @param jsExp - expression to evaluate in the script.
- * can be a function or another valid javascript expression
- * @return false if the file is not found or the file does not contain the specified function (the expression can't be evaluated)
- * It will also return false if the operation was canceled by calling cancelScript(true).
- **/
- method.runScript = function (/*String*/ scriptPath,/*String*/ jsExp) {
- return this.getFSIApp().RunFSI(scriptPath, jsExp);
- }
- /**
- * Communicates to Fusion that the current operation (started with runScript) is cancelled.
- * (Fusion will check on return of the script the property set by this method to determine
- * whether the script was canceled or not)
- * @param cancel - true if the script is canceled
- **/
- method.cancelScript = function (/*boolean*/ cancel) {
- this.getFSIApp().Cancel = cancel;
- }
- /**
- * Get the status of currently running script in Fusion,
- * whether the script was canceled or not.
- * @return true if the script was canceled
- **/
- /*boolean*/ method.isScriptCanceled = function () {
- return this.getFSIApp().Cancel;
- }
-
- /**
- * Get the application's initial mode
- *
- * @return
- **/
- method.getInitMode = function () {
- return this.getFSIApp().InitMode;
- }
- /**
- * Set the application's initial mode
- *
- * @param initMode
- **/
- method.setInitMode = function (/*int*/ initMode) {
- this.getFSIApp().InitMode = initMode;
- }
-
- /**
- * Get the application's exe file path
- *
- * @return the path to Fusion.exe
- **/
- method.getExeLocation = function () {
- return this.getFSIApp().AppDirectory; //? + "Fusion.exe";
- }
-
- /**
- * Get the application's System Directory file path
- *
- * @return the path to NetObjects System folder
- **/
- method.getSystemDirectory = function () {
- return this.getFSIApp().SystemDirectory;
- }
-
- /**
- * Get the profiles base path
- *
- * @return the path to profiles folder for current user
- **/
- method.getProfilesPath = function () {
- var fsiConfigFile = new ActiveXObject(NOF.ProgId.FSIProfile);
- var profilePath = fsiConfigFile.GetProfilePath();
- fsiConfigFile = null;
- return profilePath;
- }
-
- /**
- * Get the Fusion serial number
- *
- * @return the string representing Fusion Serial Number
- **/
- method.getSerialNumber = function () {
- return this.getFSIApp().SerialNumber;
- }
-
- /**
- * Defines the version of the FSI API.
- *
- * @return a string representing the version of the FSI API.
- **/
- method.getSDKVersionNumber = function () {
- return this.getFSIApp().VersionNumber;
- }
-
- /**
- * Defines the version of running Fusion
- *
- * @return a string representing the version of the Fusion.
- **/
- method.getVersion = function () {
- var nofSettingsObj = new NOF.NOFSettings();
- var fusionVersion = nofSettingsObj.get( "Version", NOF.NOFSettings.STRING_VALUE );
- nofSettingsObj = null;
- return fusionVersion;
- }
-
- /**
- * sets the value of a new or existing system variable.
- *
- * @param pName name of the variable
- * @param pValue value of the variable
- **/
- method.setVariable = function (/*String*/ pName, /*String*/ pValue) {
- this.getFSIApp().SetSystemVar(pName, pValue);
- }
-
- /**
- * Returns the value of a system variable. If the variable is not defined
- * the function will return an empty string.
- *
- * @param pName name of the variable
- * @return the value of the pName system variable
- **/
- method.getVariable = function (/*String*/ pName) {
- return this.getFSIApp().GetSystemVar(pName);
- }
-
- /**
- * When defining a password you can define the context for which the password is valid,
- * e.g.: SetPassword(passwordName, password, 'http://www.netobjects.com')
- * @param passwordName defines a name for the password
- * @param password defines the actual password.
- * @param context specifies the context for the password, which means that
- * the password can be inserted only in URLs that start with the specified context.
- * In functions accepting a URL the password can then be specified using the string:
- * %pw_<passwordName>%
- * If the password name is found and the context is valid the string will be replaced by
- * the actual password. Please note that the passwords are global, so it is important that
- * everyone using passwords is careful about the naming. For this reason each company
- * should include a company and maybe project specific identification in the name of each password.
- * All passwords defined by NetObjects will contain the identification 'nof_'
- *
- **/
- method.setPassword = function (/*String*/ passwordName,/*String*/ password,/*String*/ context) {
- this.getFSIApp2().SetGlobalPassword(passwordName, password, context);
- }
-
- /**
- * HasPassword verify if a password was defined or not.
- * Passwords are defined using the function SetPassword.
- * @param passwordName
- * @return a boolean specifying whether a password with the specified name is defined.
- **/
- method.hasPassword = function (/*String*/ passwordName) {
- return this.getFSIApp2().HasGlobalPassword(passwordName);
- }
-
- /**
- * Get the location of a temporary directory available for Fusion scripts.
- * If the directory does not already exist it will be created.
- * (You should use the temporary directory only within the execution of a single Fusion script).
- * The directory and content may be deleted by any Fusion script.
- *
- * @return the path to the temporary folder in Fusion.
- **/
- method.getTempDirectory = function () {
- return this.getFSIApp().GetTempDir();
- }
-
- /**
- * Deletes the temporary directory (see getTempDirectory).
- *
- **/
- method.deleteTempDirectory = function () {
- this.getFSIApp().DeleteTempDir();
- }
-
- /**
- * Returns the path of a recent Fusion site file.
- * @param pNumber specifies a number of the recent file, where 0 is the most recent.
- * The function returns an empty string if there are no more recent files.
- *
- **/
- method.getRecentSiteLocation = function (/*int*/ pNumber) {
- return this.getFSIApp().GetRecentSite(pNumber);
- }
-
- /**
- * Specifies the view that should be opened.
- *
- * @param pView. The possible values are:
- * 0 : site view, 1 : page view, 2 : style view, 3 : assets view, 4 : publish view, 5 : service view.
- *
- **/
- method.setCurrentView = function (/*int*/ pView) {
- this.getFSIApp().SetCurrentView(pView);
- }
-
- /**
- * Creates a new blank site (and opens it).
- * If successful the previously open site (if any) will be closed.
- *
- * @return a NOF.Site object if the call succeeds
- **/
- method.newSite = function (/*String*/ sitePath) {
- var siteCreated = this.getFSIApp().NewBlankSite(sitePath);
- var site = null;
- if (siteCreated == true) {
- site = new NOF.Site(sitePath);
- }
- return site;
- }
-
- /**
- * Opens the site specified by the sitePath. If successful the previously open site (if any) will be closed.
- * @param sitePath path to the .nod file
- * @param openPageView (optional - if defined, sitePath must be an integer - index of the site in the 'recent site list'),
- * if true the site will be opened in Page view at the last opened page, otherwise the site will be opened in Site view
- * @return a NOF.Site object if the call succeeds (or a boolean indicating the success of the operation)
- **/
- method.openSite = function (/*String*/ sitePath, /*boolean*/ openPageView) {
- if (arguments.length == 2 /* && openPageView != null*/) {
- return this.getFSIApp2().OpenRecentSite(/*int*/ sitePath, openPageView);
- }
-
- var site = null;
- var siteOpened = false;
-
- if (this.getFSIApp().IsSiteOpen(sitePath) == false) {
- siteOpened = this.getFSIApp().OpenSite(sitePath);
- } else {
- siteOpened = true;
- }
- if (siteOpened == true) {
- site = new NOF.Site(sitePath);
- }
- return site;
- }
-
- /**
- * Returns the currently open site.
- *
- * @return most recent opened site or null if there is no site open.
- *
- **/
- method.getCurrentSite = function () {
- var cSite = new NOF.Site(this.getRecentSiteLocation(0));
- if (cSite.isOpen()) {
- return cSite;
- } else {
- return null;
- }
- }
-
- /**
- * Get the path to the scripts lib folder.
- *
- * @return the path to the scripts lib folder.
- **/
- method.getScriptsDirectory = function () {
- return (this.getSystemDirectory() + this.PATH_SEPARATOR + "Fsi" + this.PATH_SEPARATOR + "lib");
- }
-
- /**
- * Add a new path to the scripts classpath
- * @param pathsArray array of paths to Fusion folders
- **/
- method.addLibsPath = function (/*String[]*/ pathsArray) {
- if ( pathsArray != null ) {
- var path;
- for (var i=0; i < pathsArray.length; i++) {
- path = pathsArray[i];
- if (this.libsPath.containsItem(path) < 0) {
- this.libsPath.add(path);
- }
- }
- }
- }
-
- /**
- * Get classpath to scripts/modules
- * @return an array of paths to Fusion folders
- **/
- method.getLibsPath = function () {
- var path = this.getSystemDirectory() + this.PATH_SEPARATOR + "Fsi";
- if (this.libsPath.containsItem(path) < 0) {
- this.addLibsPath([path]);
- }
- return this.libsPath;
- }
- method.setLibsPath = function (libsPath) { this.libsPath = libsPath; }
-
- /**
- * Get the file path separator.
- * @see NOF.IO.File
- * @return the file path separator. as a string
- **/
- method.getPathSeparator = function () {
- return this.PATH_SEPARATOR;
- }
-
- /**
- * Get the file line separator.
- * @see NOF.IO.File
- * @return
- **/
- method.getLineBreak = function () {
- return this.LINE_BREAK;
- }
-
- /**
- * Get Date format
- *
- * @return
- **/
- method.getDateFormat = function () {
- // TODO:
- }
-
- /**
- * Get Number format
- *
- * @return
- **/
- method.getNumberFormat = function () {
- // TODO:
- }
-
- /**
- * Get default locale
- *
- * @return a NOF.UTIL.Locale instance corresponding to current Fusion's settings.
- **/
- /*NOF.UTIL.Locale*/ method.getDefaultLocale = function () {
- var cfgObj = new NOF.NOFSettings();
- var localeStr = cfgObj.get("locale", NOF.NOFSettings.STRING_VALUE);
- cfgObj = null;
-
- if (localeStr == null || localeStr.length == 0) {
- localeStr = "enUS";
- }
-
- var NOF_Language = localeStr.substring(0,2);
- var NOF_Country = (localeStr.length==4)?(localeStr.substring(2,4).toUpperCase()):null;
- return new NOF.UTIL.Locale(NOF_Language, NOF_Country);
- }
- }
-
- NOF.__proto__.App = new NOF_App();
-
- }